﻿using JewererBasic.BO;
using JewererBasic.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace JewererBasic.Controllers
{
    public class ComponentReportController : Controller
    {
        public ActionResult ViewHistory()
        {
            this.setviewbag();
            ComponentHistoryModel model = new ComponentHistoryModel();
            model.TimeFrom = DateTime.Now;
            model.TimeTo = DateTime.Now;
            model.TypeReport = "Export";
            return View(model);
        }

        [HttpPost]
        public ActionResult ViewHistory(ComponentHistoryModel model)
        {
            if (model.TimeTo == null || model.TimeFrom == null)
                model.TimeFrom = model.TimeTo = null;
            if (string.IsNullOrEmpty(model.Component_Id) == true)
                model.Component_Id = null;

            ComponentHistoryBO.GetComponentExport(model);

            this.setviewbag();
            return View(model);
        }

        void setviewbag()
        {
            List<string> lstType = new List<string>();
            lstType.Add("Import");
            lstType.Add("Export");

            List<string> lstKindReciever = new List<string>();
            lstKindReciever.Add("All");
            lstKindReciever.Add("Bag");
            lstKindReciever.Add("Staff");
            lstKindReciever.Add("Order_Tree");
            lstKindReciever.Add("Order_Component");

            ViewBag.ListTypeReport = new SelectList(lstType);
            ViewBag.KindReciever = new SelectList(lstKindReciever);
        }

    }
}
